package A01;

import java.util.Scanner;


public class D0701 {
    public static void main (String[] args) {
        int a=0;
        int b=1;
        int c=1;
        Scanner scanner=new Scanner (System.in);
        int in=scanner.nextInt ();

        while(in>b){
            c=a+b;
            a=b;
            b=c;
        }

        int out=(b-in)<(in-a)?(b-in):(in-a);
        System.out.println (out);
    }
}
